package com.demo.cotroller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wangzhanjin on 2018/6/8.
 */
@Controller
public class HomeController {

    @RequestMapping("/")
    @ResponseBody
    public String hello() {
        return "黄河之水天上来";
    }

    @RequestMapping("/error.api")
    @ResponseBody
    public String errorApi() {
        throw new RuntimeException("意外啦Api");
    }

    @GetMapping("/index")
    public String index(Model model) {
        model.addAttribute("name", "实在是太帅了");
        return "index";
    }
}
